﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace eShop.Web.Admin.Models
{
    public class ReceiveModule : IValidatableObject
    {
        public DataTable ReceiveList { get; set; }

        [Display(Name = "入库单号")]
        [Required(ErrorMessage = "单号不能为空")]
        [StringLength(20, ErrorMessage = "单号长度不能大于20")]
        public string ReceiveNo { get; set; }
        public DateTime ReceiveDate { get; set; }

        [Range(1, int.MaxValue, ErrorMessage = "请选择正确的仓库")]
        public int StockId { get; set; }

        [Range(1, int.MaxValue, ErrorMessage = "请选择正确的商品信息")]
        public int PId { get; set; }

        [Range(1, int.MaxValue, ErrorMessage = "请输入正确的数量")]
        public int ReceiveNum { get; set; }

        [StringLength(20, ErrorMessage = "长度不能大于20")]
        public string DoPerson { get; set; }
        [StringLength(100, ErrorMessage = "长度不能大于100")]
        public string Remark { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrWhiteSpace(ReceiveNo))
            {
                yield return new ValidationResult("入库单号不能为空", new string[] { "ReceiveNo" });
            }
        }
    }
}
